import BScroll from 'better-scroll';
export default function initscroll(querystr,refre,load){
        const wrapper = document.querySelector(querystr)
        //选中DOM中定义的 .wrapper 进行初始化
        const scroll = new BScroll(wrapper, {
          scrollX: false,  
          click: true,  // better-scroll 默认会阻止浏览器的原生 click 事件
          scrollY: true, 
        })
        scroll.on('touchEnd',function(position){
            if(position.y>100){
                refre()
               setTimeout( ()=>{
                console.log('该刷新了')
                    scroll.refresh()
                    position.y=40
                    console.log('重新计算高度了')
               },1000)
            }
            else if(position.y < (this.maxScrollY -50 )){
                console.log('该加载了')
                console.log(position.y)
                    load()
                setTimeout( async()=>{
                    scroll.refresh()
                    console.log('重新计算高度了')
                   },1000)
            }
        })
}